O2O: logback tutorial

Logback

Description

Logback is a log module.
Logback-2019-8-1-12-20-49.png

Logback-2019-8-1-12-21-24.png

logger, appender, layout are tags of logback

Configuration

  1. Create a logback.xml in resources package

Logback-2019-11-10-12-31-22.png

  1. Defines some properties of the logback configuration.

Logback-2019-11-10-12-52-52.png

  1. Defines the appenders.

Logback-2019-11-10-13-1-13.png

Logback-2019-11-10-14-3-39.png

Info, Error is the same as Debug.
Logback-2019-11-10-14-4-14.png

Logback-2019-11-10-14-7-21.png

  1. Defines the logger

Logback-2019-11-10-14-19-22.png

Logback-2019-11-10-14-19-41.png

Debug: We should change all MaxHistory to maxHistory in the appenders.
Debug: We should change all append-ref to appender-ref in the appenders.

Practice

  1. Initialize a Logger instance in the AreaController.

2_Logback-2019-11-10-14-28-29.png

  1. Add some test info statements in the function.

2_Logback-2019-11-10-14-48-50.png

  1. Check the console and the file.
    2_Logback-2019-11-10-14-49-12.png

Here we can search catalina.base to get to the directory of our log files.
2_Logback-2019-11-10-14-52-23.png

2_Logback-2019-11-10-14-51-30.png